package com.digitalchina.lxnsy.viewholder;

import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.AnswerVO;
import com.digitalchina.lxnsy.toolkit.DateStyle;
import com.digitalchina.lxnsy.toolkit.DateUtil;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：白彦东
 * 创建时间：2016/12/28 18:10
 * 修改备注：
 * ================================================
 */

public class AnswerHolder extends BaseViewHolder<AnswerVO> {

    private TextView tvAnswerQuestion;
    private TextView tvAnswerContent;
    private TextView tvAnswerPraise;
    private TextView tvAnswerDate;


    public AnswerHolder(ViewGroup parent) {
        super(parent, R.layout.item_my_answer);
        tvAnswerQuestion = $(R.id.item_tv_answer_question);
        tvAnswerContent = $(R.id.item_tv_answer_content);
        tvAnswerPraise = $(R.id.item_tv_answer_praise);
        tvAnswerDate = $(R.id.item_tv_answer_date);
    }

    @Override
    public void setData(AnswerVO data) {
        super.setData(data);

        if (null != data.getQuestion()){
            tvAnswerQuestion.setText(data.getQuestion().getTitle() != null ? data.getQuestion().getTitle() : "");
        }
        tvAnswerContent.setText(String.format("%s个回答", data.getWordContent() == null ? "" : data.getWordContent()));
        tvAnswerPraise.setText(String.format("%s赞同", data.getPraiseCount()));
        tvAnswerDate.setText(DateUtil.StringToString(data.getCreateAt(), DateStyle.YYYY_MM_DD_EN));
    }

}
